
import flash.display.Sprite;

//Keyboard Events
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.MouseEvent;


class UIView extends Sprite
{
  private var _model:AVerletModel;
  private var _controller:UIController;
  private var _stage:Dynamic;

  public function new(model:AVerletModel, controller:UIController, stage:Dynamic)
  {
    super();
    this._model = model;
    this._controller = controller;
    this._stage = stage;
    
    _stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
    _stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler);
//     _stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
//     _stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
  }
  private function keyDownHandler(event:KeyboardEvent)
  {
    _controller.processKeyDown(event);
  }
  private function keyUpHandler(event:KeyboardEvent)
  {
    _controller.processKeyUp(event);
  }
  private function mouseDownHandler(event:MouseEvent)
  {
    _controller.processMouseDown(event, _stage);
  }
  private function mouseUpHandler(event:MouseEvent)
  {
    _controller.processMouseUp(event);
  }
}